USE [AnotherSuccessfulProcedure]

IF EXISTS (SELECT * FROM sysobjects WHERE id = object_id(N'[dbo].[MedicChargeSelectTop5PlayersByChargeType]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1)
BEGIN
	DROP PROCEDURE dbo.MedicChargeSelectTop5PlayersByChargeType
END


SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:		Neil Wilson
-- Create date: 09/03/08
-- Description:	Medic Charge Table Select - Top 5 of a given Charge Type
-- =============================================
CREATE PROCEDURE MedicChargeSelectTop5PlayersByChargeType
	@ChargeType varchar(30)
AS

BEGIN

SELECT TOP 5 PlayerName, COUNT(ChargeId) AS [Charges], MedicCharge.PlayerId
FROM MedicCharge INNER JOIN PlayerNameList on MedicCharge.Playerid = PlayerNameList.PlayerId
WHERE ChargeType = @ChargeType
GROUP BY PlayerName, MedicCharge.PlayerId
ORDER BY [Charges] DESC

END
GO

--  MedicChargeSelectTop5PlayersByChargeType 'chargedeployed'
